package com.javaee.xiangyang.mapper;

import com.javaee.xiangyang.entity.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface OrderMapper {


    /**
     * 生成订单
     */
//    @Insert("insert into `order` values(#{orderId}, #{orderStart}, 1, #{orderEnd}, #{orderGoodsId}, #{orderGoodsNumber}, #{orderShopTotal}, #{orderUserAccount})")
    void insertOrder(Order order);

    /**
     * 根据用户Id查询用户所拥有订单
     */
//    @Select("select * from `order` where orderUserAccount = #{orderUserAccount}")
    List<Order> findOrderByUserAccount(Order order);

    /**
     * 根据订单编号查询具体订单信息
     */
//    @Select("select * from `order` where orderId = #{orderId}")
    Order findOrderByOrderId(Order order);

    /**
     * 查看所有订单
     */
//    @Select("select * from `order`")
    List<Order> findAllOrder();

    /**
     * 订单状态改变
     */
//    @Update("update `order` set orderState = #{orderState}, orderEnd = #{orderEnd} where orderId = #{orderId}")
    void updateOrderStateByOrderId(Order order);

    /**
     * 根据订单状态查找订单
     */
//    @Select("select * from `order` where orderState = #{orderState}")
    List<Order> findOrderByState(Order order);
}
